import java.util.Arrays;
import java.util.Scanner;

public class Text {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int[][] array={{1,2,3},{4,5,6}};
        System.out.println(array[0]);
        System.out.println(array[1]);
        System.out.println(array.length);
        System.out.println(array[0].length);
        System.out.println(array[1].length);
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]+" ");
            }
            System.out.println();
        }
        System.out.println("-------------");
        for(int[] arr:array){
            for(int x:arr){
                System.out.print(x+" ");
            }
            System.out.println();
        }
        System.out.println("-------------");
        System.out.println(Arrays.deepToString(array));
        int[][] array1=new int[][]{{1,2,3},{4,5,6}};
        int[][] array2=new int[2][3];
        for (int i = 0; i < array2.length; i++) {
            for (int j = 0; j < array2[i].length; j++) {
                array2[i][j]=sc.nextInt();
            }
        }
        for(int[] arr:array2){
            for(int x:arr){
                System.out.print(x+" ");
            }
            System.out.println();
        }


        int[][] array3=new int[2][];

    }
    public static void main14(String[] args) {
        int[] ret=new int[10];
        Arrays.fill(ret,-1);
        System.out.println(Arrays.toString(ret));
        Arrays.fill(ret,0,3,8);
        System.out.println(Arrays.toString(ret));
    }
    public static void main13(String[] args) {
        int[] array1={1,5,6,9,7,0,18,26};
        int[] array2={1,5,6,9,7,0,18,26};
        System.out.println(array1==array2);
        boolean flg=Arrays.equals(array1,array2);
        System.out.println(flg);
    }
    public static void main12(String[] args) {
        int[] array={1,5,6,9,7,0,18,26};
        int[] copy=Arrays.copyOf(array,array.length*2);//也可以扩容
        System.out.println(Arrays.toString(copy));
        copy=Arrays.copyOfRange(array,1,5);
        System.out.println(Arrays.toString(copy));
    }
    public static void bubblesort(int[] array){
        for (int i = 0; i < array.length-1; i++) {
            boolean flg=false;
            for (int j = 0; j <array.length-1-i; j++) {
                if(array[j]>array[j+1])
                {
                    int tmp=array[j];
                    array[j]=array[j+1];
                    array[j+1]=tmp;
                    flg=true;
                }
            }
            if(flg==false)
                return;
        }
    }
    public static void main11(String[] args) {
        int[] array={1,5,6,9,7,0,18,26};
        bubblesort(array);
        System.out.println(Arrays.toString(array));
    }
    public static void main10(String[] args) {
        int[] array={1,32,23,5,61};
        System.out.println(Arrays.toString(array));
        Arrays.sort(array);//从小到大
        System.out.println(Arrays.toString(array));
        int index=Arrays.binarySearch(array,23);//Java中自带二分查找函数
        System.out.println(index);
        int index1=Arrays.binarySearch(array,1,3,23);
        System.out.println(index1);
        index1=Arrays.binarySearch(array,1,3,32);//[1,3)Java中都是左闭右开
        System.out.println(index1);

    }
    public static void main9(String[] args) {
        int[] arr = {1,2,3,4,5,6};
        System.out.println(avg(arr));
        String str1=1+"qq";
        System.out.println(str1);
        char[] arr1={'q','2','w','r'};
        for (int i = 0; i < arr1.length; i++) {
            System.out.println(arr1[i]);
        }
    }
    public static double avg(int[] arr) {
        int sum = 0;
        for (int x : arr) {
            sum += x;
        }
        return (double)sum / (double)arr.length;
    }
    public static String myToString(int[] array){
        String ret="[";
        for (int i = 0; i < array.length; i++) {
            ret+=array[i];
            if(i!=array.length-1)
                ret+=",";
        }
        ret+="]";
        return ret;
        //String str2 = String.valueOf(num);数字转字符串类型
    }
    public static void main8(String[] args) {
        int[] array={1,2,3,4,5};
        String str1= String.valueOf(array.length);
        System.out.println(str1);
        System.out.println(myToString(array));
    }
    public static int[] fib(int n){
        if(n<=0)
            return null;
        int[] arr=new int[10];
        arr[0]=arr[1]=1;
        for (int i = 2; i < n; i++) {
            arr[i]=arr[i-1]+arr[i-2];
        }
        return arr;
    }
    public static void main7(String[] args) {
        int[] array=fib(10);
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
    }
    public static int[] fun(int[] array){
        int[] ret=new int[array.length];
        for (int i = 0; i < array.length; i++) {
            ret[i]=2*array[i];
        }
        return ret;
    }
    public static void main6(String[] args) {
        //int[] array=new int[]{1,2,3,4,5};
        int[] array={1,2,3,4,5};
        int[] tmp=fun(array);
        System.out.println(Arrays.toString(array));
        System.out.println(Arrays.toString(tmp));
    }
    public static void main5(String[] args) {
        Scanner sc=new Scanner(System.in);
        int size=sc.nextInt();
        int[] array=new int[size];
        for (int i = 0; i < size; i++) {
            array[i]=sc.nextInt();
        }
        String ret=Arrays.toString(array);
        System.out.println(ret);
        Arrays.sort(array);
        System.out.println(Arrays.toString(array));
    }
    public static void main4(String[] args) {
        int[] array1 = new int[3];
        array1[0] = 10;
        array1[1] = 20;
        array1[2] = 30;//堆中开辟三个int类型空间 没有一直被引用就会被JVM自动回收
        int[] array2 = new int[]{1,2,3,4,5};
        array2[0] = 100;
        array2[1] = 200;
        array1 = array2;
        array1[2] = 300;
        array1[3] = 400;
        array2[4] = 500;
        for (int i = 0; i < array2.length; i++) {
            System.out.println(array2[i]);
        }
        for (int i = 0; i < array1.length; i++) {
            System.out.println(array1[i]);
        }
    }
    public static void main3(String[] args) {
        int[] array={1,2,3,4,5};
        System.out.println(array);
        System.out.println(array.length);
    }
    public static void main2(String[] args) {
        int[] array={1,2,3,4,5};
        String ret=Arrays.toString(array);
        System.out.println(ret);
    }
    public static void main1(String[] args) {
        Scanner sc=new Scanner(System.in);
        int[] arr=new int[10];
        for (int i = 0; i < 10; i++) {

        }
        for (int i = 0; i < 10; i++) {
            System.out.println(arr[i]);
        }
    }
}
